package com.openbravo.pos.printer.screen;

import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Insets;
import java.awt.Rectangle;
import javax.swing.JPanel;

class JTicketContainer extends JPanel
{
  protected int H_GAP = 8;
  protected int V_GAP = 8;

  public JTicketContainer()
  {
    initComponents();
    setLayout(null);
  }

  public Dimension getPreferredSize()
  {
    Insets localInsets = getInsets();
    int i = 0;
    int j = localInsets.top + this.V_GAP;
    int k = getComponentCount();
    for (int m = 0; m < k; m++)
    {
      Component localComponent = getComponent(m);
      Dimension localDimension = localComponent.getPreferredSize();
      if (localDimension.width > i)
        i = localDimension.width;
      j += this.V_GAP + localDimension.height;
    }
    return new Dimension(i + 2 * this.H_GAP + localInsets.left + localInsets.right, j + localInsets.bottom);
  }

  public Dimension getMaximumSize()
  {
    return getPreferredSize();
  }

  public Dimension getMinimumSize()
  {
    return getPreferredSize();
  }

  public void doLayout()
  {
    Insets localInsets = getInsets();
    int i = localInsets.left + this.H_GAP;
    int j = localInsets.top + this.V_GAP;
    int k = getComponentCount();
    for (int m = 0; m < k; m++)
    {
      Component localComponent = getComponent(m);
      Dimension localDimension = localComponent.getPreferredSize();
      localComponent.setBounds(i, j, localDimension.width, localDimension.height);
      j += this.V_GAP + localDimension.height;
    }
  }

  public void addTicket(JTicket paramJTicket)
  {
    add(paramJTicket);
    doLayout();
    revalidate();
    scrollRectToVisible(new Rectangle(0, getPreferredSize().height - 1, 1, 1));
  }

  public void removeAllTickets()
  {
    removeAll();
    doLayout();
    revalidate();
    scrollRectToVisible(new Rectangle(0, 0, 1, 1));
  }

  private void initComponents()
  {
    setLayout(new BorderLayout());
  }
}

/* Location:           D:\PowerFulPOS-2.30.2\openbravopos.jar
 * Qualified Name:     com.openbravo.pos.printer.screen.JTicketContainer
 * JD-Core Version:    0.6.0
 */